package o;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import com.huawei.appgallery.forum.base.https.jgw.JGWTabDetailResponse;
import com.huawei.appgallery.forum.cards.bean.ForumTitleSortCardBean;
import com.huawei.appgallery.forum.cards.node.BuoyForumTitleSortNode;
import com.huawei.appgallery.forum.posts.card.ForumPostDetailHeadCardBean;
import com.huawei.appgallery.forum.posts.card.ForumTopicCommentCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import java.util.List;

public class bzl extends bss {
    private buk ʼॱ;
    private BroadcastReceiver ʽॱ = new d();
    private BroadcastReceiver ʾ = new b();
    private int ʿ = -1;
    private int ˈ = -1;
    private bzk ˉ;
    private int ˋˊ = 0;
    private bzi ॱˋ;
    private int ॱˎ = 0;
    private bzn ᐝॱ;

    class b extends BroadcastReceiver {
        final /* synthetic */ bzl ˎ;

        private b(bzl o_bzl) {
            this.ˎ = o_bzl;
        }

        public void onReceive(Context context, Intent intent) {
            if (intent != null) {
                if ("forum.comments.list.refresh".equals(intent.getAction())) {
                    evr.ˊ().ᐝ();
                    this.ˎ.ˊ(intent.getIntExtra("notify_type", -1));
                }
            }
        }
    }

    class d extends BroadcastReceiver {
        final /* synthetic */ bzl ˏ;

        private d(bzl o_bzl) {
            this.ˏ = o_bzl;
        }

        public void onReceive(Context context, Intent intent) {
            if (intent != null) {
                String action = intent.getAction();
                if ("com.huawei.appgallery.forum.posts.refreshlist".equals(action)) {
                    this.ˏ.ˍ();
                } else if ("com.huawei.appgallery.forum.posts.deletecomment".equals(action)) {
                    this.ˏ.ˊ(intent.getLongExtra("comment_id", 0));
                }
            }
        }
    }

    public void ˊ(bzk o_bzk) {
        this.ˉ = o_bzk;
    }

    public void ॱ(Bundle bundle) {
        super.ॱ(bundle);
    }

    public void onDestroy() {
        super.onDestroy();
    }

    protected void ॱᐝ() {
        super.ॱᐝ();
        IntentFilter intentFilter = new IntentFilter();
        IntentFilter intentFilter2 = new IntentFilter();
        intentFilter.addAction("com.huawei.appgallery.forum.posts.refreshlist");
        intentFilter.addAction("com.huawei.appgallery.forum.posts.deletecomment");
        intentFilter2.addAction("forum.comments.list.refresh");
        Context ˉ = ˉ();
        if (ˉ != null) {
            ll.ˏ(ˉ).ˏ(this.ʽॱ, intentFilter);
            ll.ˏ(ˉ).ˏ(this.ʾ, intentFilter2);
        }
    }

    protected void ʻॱ() {
        super.ʻॱ();
        Context ˉ = ˉ();
        if (ˉ != null) {
            ll.ˏ(ˉ).ˋ(this.ʽॱ);
            ll.ˏ(ˉ).ˋ(this.ʾ);
        }
    }

    protected cia ˋ(Context context) {
        this.ᐝॱ = new bzo(context);
        return this.ᐝॱ;
    }

    public void ˏ(bzi o_bzi) {
        this.ॱˋ = o_bzi;
    }

    public void ˊ(buk o_buk) {
        this.ʼॱ = o_buk;
    }

    protected void ˏॱ() {
        super.ˏॱ();
        Bundle ˊˊ = ˊˊ();
        if (ˊˊ != null) {
            this.ॱˎ = ˊˊ.getInt("SOURCETYPE", 0);
        } else {
            bqx.ॱ("ForumPostDetailSegment", "parserArguments, arguments is null");
        }
    }

    protected void ˏ(BaseRequest o_cvu, ResponseBean responseBean) {
        super.ˏ(o_cvu, responseBean);
        if (ˌ() != null) {
            if (!(ˌ().ˏ(0) == null || ˌ().ˏ(0).ˏ() == null || !(ˌ().ˏ(0).ˏ().get(0) instanceof ForumPostDetailHeadCardBean))) {
                ((ForumPostDetailHeadCardBean) ˌ().ˏ(0).ˏ().get(0)).ˏ(this.ॱˎ);
            }
            for (chz o_chz : ˌ().ʻॱ()) {
                if (!(o_chz.ˏ() == null || o_chz.ˏ().isEmpty() || !(o_chz.ˋ instanceof BuoyForumTitleSortNode))) {
                    ((btd) o_chz).ॱ(this.ʼॱ);
                }
            }
        }
        if (responseBean instanceof JGWTabDetailResponse) {
            ॱ((JGWTabDetailResponse) responseBean);
        }
        if (this.ˈ != -1 && this.ʿ != -1) {
            this.mListView.setSelectionFromTop(this.ˈ, this.ʿ);
            this.ˈ = -1;
            this.ʿ = -1;
        }
    }

    private void ॱ(JGWTabDetailResponse jGWTabDetailResponse) {
        int i;
        List<LayoutData> ᐝॱ = jGWTabDetailResponse.ᐝॱ();
        if (ᐝॱ == null || ᐝॱ.size() <= 0) {
            i = 0;
        } else {
            i = 0;
            for (LayoutData layoutData : ᐝॱ) {
                int i2;
                if (ForumPostDetailHeadCardBean.BUOYNAME.equals(layoutData.ˏ()) && layoutData.ˋ().size() > 0 && (layoutData.ˋ().get(0) instanceof ForumPostDetailHeadCardBean)) {
                    this.ॱˋ.ॱ((ForumPostDetailHeadCardBean) layoutData.ˋ().get(0), this.ˊ, jGWTabDetailResponse.ʻ());
                }
                if ((ForumTopicCommentCardBean.BUOYNAME.equals(layoutData.ˏ()) || ForumTitleSortCardBean.BUOYNAME.equals(layoutData.ˏ())) && !CollectCheck.isEmpty(layoutData.ˋ())) {
                    i2 = 1;
                } else {
                    i2 = i;
                }
                i = i2;
            }
            if (i != 0) {
                ˎ(jGWTabDetailResponse, ᐝॱ);
            }
        }
        if (i == 0 && this.ᐝॱ != null) {
            this.ᐝॱ.ˊ();
        }
    }

    private void ˎ(JGWTabDetailResponse jGWTabDetailResponse, List<LayoutData> list) {
        if (jGWTabDetailResponse.ʻ() > 0) {
            for (LayoutData layoutData : list) {
                if (ForumTopicCommentCardBean.BUOYNAME.equals(layoutData.ˏ())) {
                    for (ForumTopicCommentCardBean ˎ : layoutData.ˋ()) {
                        ˎ.ˎ(jGWTabDetailResponse.ʻ());
                    }
                }
            }
        }
    }

    protected void ˋᐝ() {
        if (bsp.ˋ()) {
            super.ˋᐝ();
        }
    }

    protected void ˋˋ() {
        if (bsp.ˋ()) {
            super.ˋˋ();
        }
    }

    public void ˍ() {
        if (this.ᐝॱ != null) {
            this.ᐝॱ.ͺ();
        }
    }

    private void ˊ(long j) {
        if (this.ᐝॱ != null) {
            this.ᐝॱ.ॱ(j, true);
            this.ᐝॱ.ͺ();
        }
    }

    private void ˊ(int i) {
        int i2 = 0;
        if (i >= 0 && this.ʼॱ != null && this.ʼॱ.ˎ() == i) {
            String str = this.ˊ;
            if (i == 1) {
                str = this.ˊ + ",sort_0";
            } else if (i == 0) {
                str = this.ˊ + ",sort_1";
            }
            this.ˈ = this.mListView.getFirstVisiblePosition();
            View childAt = this.mListView.getChildAt(0);
            if (childAt != null) {
                i2 = childAt.getTop();
            }
            this.ʿ = i2;
            ॱ(str);
            ˊᐝ();
        }
    }
}
